#include <iostream>
#include <string>
using namespace std;

int main()
{
	int n;
	cin >> n;
	string op;
	string num1, num2;
	
	string last;
	int ret = 0;
	while(n--)
	{
		string res;
		cin >> op;
		if(op == "a" || op == "b" || op == "c")
		{
			cin >> num1 >> num2;
			int n1 = stoi(num1);
			int n2 = stoi(num2);
			res += num1;
			if(op == "a")
			{
				ret = n1 + n2;
				res += "+";
			}
			else if(op == "b")
			{
				ret = n1 - n2;
				res += "-";
			}
			else
			{
				ret = n1 * n2;
				res += "*";
			}
			last = op;
		}
		else
		{
			num1 = op;
			cin >> num2;
			int n1 = stoi(num1);
			int n2 = stoi(num2);
			res += num1;
			if(last == "a")
			{
				ret = n1 + n2;
				res += "+";
			}
			else if(last == "b")
			{
				ret = n2 - n1;
				res += "-";
			}
			else
			{
				ret = n1 * n2;
				res += "*";
			}
		}
		res += (num2 + "=" + to_string(ret));
		cout << res << endl;
		cout << res.size() << endl;
	}
	return 0;
}
